﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.world {
    import flash.events.*;
    import flash.geom.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.world.*;

    public class CreateActorCommand extends Command {

		[Inject]
        public var event:InfoEvent;
		[Inject]
        public var worldFactory:WorldFactory;
		[Inject]
        public var worldModel:WorldModel;
		[Inject]
        public var roomSlotsModel:RoomSlotsModel;

        protected function setActor(_arg1:IActing, _arg2:String):void{
            if (!this.worldModel.getActor(_arg1.id)){
                this.worldModel.addActor(_arg1);
            };
            dispatch(new InfoEvent(_arg2, null, _arg1));
            var _local3:IRoom = (this.worldModel.getRoomById(_arg1.roomId) as IRoom);
            var _local4:Point = _local3.getTargetPositionOf(_arg1.state);
            var _local5:Point = this.roomSlotsModel.getSlotById(_local3.slotId).position;
            var _local6:Point = new Point((_local5.x + _local4.x), (_local5.y + _local4.y));
            dispatch(new InfoEvent(EventConstants.SET_TO_POSITION, _arg1.id, _local6));
            dispatch(new Event(EventConstants.UPDATE_MORE_PETS_ARROW));
        }

    }
}//package net.wooga.pets.controllers.world 
